<?php

namespace App\Models;

use App\Util\Tool;
use Illuminate\Database\Eloquent\Model;

class WorkRelateGoods extends Model
{
    protected $table = "c_work_relate_goods";

    /***
     * @return mixed
     * 获取商品的分类id
     */
    public function getCateIdsByHealth()
    {
        $goods_cate = new ProductGoods();
        $ids = $this->distinct()->pluck("goods_id");
        $where[] = [function ($query) use ($ids) {
            $query->whereIn('id', $ids);
        }];
        return $goods_cate->distinct()->where($where)->pluck("product_sort_id");
    }

    /***
     * @param $param
     * @return mixed
     * 获取工作室已有文章ID
     */
    public static function getGoodsIds($param)
    {
        return self::where([['work_id', '=', $param['work_id']]])->pluck("goods_id");
    }
}
